package com.tiyende.kash.loop.utils.helper

/**
 * CreditStatusHelper
 * @Author wwdeng
 * @CreateTime: 2024/10/21 10:44
 * @Annotation：授信状态
 * @des：/v1/beforeApplyRisk 接口得 status
 */
object TiyendeStatusHelper {

    private var creditStatus = ""

    /**
     * 缓存授信状态
     * CREATED - 未处理
     * PASSED、REJECTED - 已处理
     */
    fun saveTiyendeCreditStatus(status: String){
        creditStatus = status
    }

    class TiyendeCreditStatusRepository(){

        /**
         * 处理中(未处理)
         */
        fun isCreditReviewing(): Boolean{
            return when(creditStatus){
                CreditStatus.CREATED.name -> true
                else -> false
            }
        }

        /**
         * 授信已完成 (已处理)
         */
        fun isCreditPassed(): Boolean{
            return when(creditStatus){
                CreditStatus.REJECTED.name,
                CreditStatus.PASSED.name -> true
                else -> false
            }
        }

        /**
         * 授信已拒绝
         */
        fun isCreditRejected(beforeRiskStatus: String): Boolean{
            return when(beforeRiskStatus){
                CreditStatus.SYS_DENIED.name -> true
                else -> false
            }
        }
    }

    /**
     * 授信状态
     */
    enum class CreditStatus {
        /**
         * 授信中
         */
        CREATED,

        /**
         * 已拒绝
         */
        REJECTED,

        /**
         * 系统拒绝
         */
        SYS_DENIED,

        /**
         * 授信完成
         */
        PASSED
    }
}